<?php

$api = app('Dingo\Api\Routing\Router');

// 而 Laravel 默认只会在命名空间 App\Http\Controllers 下查找控制器，所以需要我们给出 namespace
$api->version('v1',[
    'middleware'=>['bindings'],//bindings 在 Kernel里面的routeMiddleware定义了
    'namespace' => 'App\Http\Controllers\Api\V1'
],function ($api){

    $api->group(['middleware' => 'login.jwt'], function ($api) {
        $api->get('/t', function () {
            return 'ok';
        });
        //收藏和取消收藏
        $api->post('favor','MemberController@favor')->name('member.favor');
        $api->delete('favor','MemberController@disfavor')->name('member.disfavor');

        // 加入和取出购物车
        $api->post('addcart','MemberController@addcart')->name('member.addcart');
        $api->delete('addcart','MemberController@removecart')->name('member.removecart');
       
        $api->post('logout','MemberController@logout')->name('member.logout');
        $api->post('address_list','MemberController@address_list');

        //订单生成 body 是一个 json 字符串
        $api->post('addOrder','OrderController@store')->name('order.store');

        // api 的测试地址
        $api->post('test','MemberController@test')->name('member.test');

        // 收货地址增删改 未完待续
        // $api->resource('memberAddress','MemberAddressController');
    });


    //测试地址
    $api->post('login_test','IndexController@login_test');
    $api->post('get_user','IndexController@get_user');
    //测试地址


    $api->post('vindex','VerificationCodesController@vindex');
    $api->post('hasmany','MemberController@hasmany');

    //发送短信验证码
    $api->post('verificationCodes','VerificationCodesController@store')->name('verificatonCodes.store');

    $api->post('register','MemberController@store')->name('member.store');
    $api->post('login','MemberController@login')->name('member.login');

    //产品列表
    $api->any('/','IndexController@store')->name('index.store');
    // 带 token 的产品列表（带上是否收藏）
    $api->any('index','IndexController@store')->name('index.store');
});